package com.wuyou.designPatterns.factory.abstractfactory.listfactory;

import com.wuyou.designPatterns.factory.abstractfactory.factory.Item;
import com.wuyou.designPatterns.factory.abstractfactory.factory.Tray;

import java.util.Iterator;

public class ListTray extends Tray {

    public ListTray(String caption) {
        super(caption);
    }

    @Override
    public String makeHTML() {
        StringBuffer sb = new StringBuffer();
        sb.append("<li>\n").append(caption).append("\n").append("<ul>\n");
        Iterator<Item> iterator = tray.iterator();
        while (iterator.hasNext()){
            sb.append(iterator.next().makeHTML());
        }
        sb.append("</ul>\n").append("</li>\n");
        return sb.toString();
    }
}
